package com.ruoyi.manage.strategy.Impl;

import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.manage.DTO.ChargingDTO;
import com.ruoyi.manage.strategy.BillingPolicies;
import org.omg.CORBA.SystemException;

import java.math.BigDecimal;

/**
 * @Title:
 * @BelongProjecet online-car-hailing
 * @BelongPackage com.ruoyi.manage.strategy.Impl
 * @Description: 长途计费策略
 * @Copyright
 * @Author: 马朝斌
 * @Date: 2024-07-03 19:04
 * @Version V1.0
 */
public class LongDistanceBillingPolicy implements BillingPolicies {

    /**
    * @Author 马朝斌
    * @Description //TODO 订单的长途计费策略
    * @Date 19:06 2024/7/3
    * @Param
     * @param chargingDTO
    * @return com.ruoyi.common.core.web.domain.AjaxResult
    */

    @Override
    public AjaxResult billingPolicies(ChargingDTO chargingDTO) throws SystemException {
        //获取每公里的价格
        BigDecimal longDistancePrice = chargingDTO.getLongDistancePrice();
        //获取总公里数
        Double orderDistance = chargingDTO.getOrderDistance();
        //计算总费用
        chargingDTO.setOrderPrice(longDistancePrice.multiply(BigDecimal.valueOf(orderDistance)));
        return AjaxResult.success(chargingDTO);

    }
}
